﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using GPSTrackingDBV2.Entities;
using GPSTrackingDBV2.Data;

#endregion

namespace GPSTrackingDBV2.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="EmailToSendStocksProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class EmailToSendStocksProviderBaseCore : EntityProviderBase<GPSTrackingDBV2.Entities.EmailToSendStocks, GPSTrackingDBV2.Entities.EmailToSendStocksKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByClientIdFromEmailToSendStockByClients
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by ClientID in the
		///		EmailToSendStockByClients table. Table EmailToSendStocks is related to table Clients
		///		through the (M:N) relationship defined in the EmailToSendStockByClients table.
		/// </summary>
		/// <param name="_clientId"></param>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByClientIdFromEmailToSendStockByClients(System.Int32 _clientId)
		{
			int count = -1;
			return GetByClientIdFromEmailToSendStockByClients(null,_clientId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.EmailToSendStocks objects from the datasource by ClientID in the
		///		EmailToSendStockByClients table. Table EmailToSendStocks is related to table Clients
		///		through the (M:N) relationship defined in the EmailToSendStockByClients table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_clientId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByClientIdFromEmailToSendStockByClients(System.Int32 _clientId, int start, int pageLength)
		{
			int count = -1;
			return GetByClientIdFromEmailToSendStockByClients(null, _clientId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by ClientID in the
		///		EmailToSendStockByClients table. Table EmailToSendStocks is related to table Clients
		///		through the (M:N) relationship defined in the EmailToSendStockByClients table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_clientId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByClientIdFromEmailToSendStockByClients(TransactionManager transactionManager, System.Int32 _clientId)
		{
			int count = -1;
			return GetByClientIdFromEmailToSendStockByClients(transactionManager, _clientId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by ClientID in the
		///		EmailToSendStockByClients table. Table EmailToSendStocks is related to table Clients
		///		through the (M:N) relationship defined in the EmailToSendStockByClients table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_clientId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByClientIdFromEmailToSendStockByClients(TransactionManager transactionManager, System.Int32 _clientId,int start, int pageLength)
		{
			int count = -1;
			return GetByClientIdFromEmailToSendStockByClients(transactionManager, _clientId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by ClientID in the
		///		EmailToSendStockByClients table. Table EmailToSendStocks is related to table Clients
		///		through the (M:N) relationship defined in the EmailToSendStockByClients table.
		/// </summary>
		/// <param name="_clientId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByClientIdFromEmailToSendStockByClients(System.Int32 _clientId,int start, int pageLength, out int count)
		{
			
			return GetByClientIdFromEmailToSendStockByClients(null, _clientId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by ClientID in the
		///		EmailToSendStockByClients table. Table EmailToSendStocks is related to table Clients
		///		through the (M:N) relationship defined in the EmailToSendStockByClients table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_clientId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of EmailToSendStocks objects.</returns>
		public abstract TList<EmailToSendStocks> GetByClientIdFromEmailToSendStockByClients(TransactionManager transactionManager,System.Int32 _clientId, int start, int pageLength, out int count);
		
		#endregion GetByClientIdFromEmailToSendStockByClients
		
		#region GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStockFiles table. Table EmailToSendStocks is related to table StockFiles
		///		through the (M:N) relationship defined in the EmailToSendStockByStockFiles table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(System.Int32 _companyId, System.Int32 _stockFileId)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(null,_companyId, _stockFileId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStockFiles table. Table EmailToSendStocks is related to table StockFiles
		///		through the (M:N) relationship defined in the EmailToSendStockByStockFiles table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(System.Int32 _companyId, System.Int32 _stockFileId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(null, _companyId, _stockFileId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStockFiles table. Table EmailToSendStocks is related to table StockFiles
		///		through the (M:N) relationship defined in the EmailToSendStockByStockFiles table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _stockFileId)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(transactionManager, _companyId, _stockFileId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStockFiles table. Table EmailToSendStocks is related to table StockFiles
		///		through the (M:N) relationship defined in the EmailToSendStockByStockFiles table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _stockFileId,int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(transactionManager, _companyId, _stockFileId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStockFiles table. Table EmailToSendStocks is related to table StockFiles
		///		through the (M:N) relationship defined in the EmailToSendStockByStockFiles table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(System.Int32 _companyId, System.Int32 _stockFileId,int start, int pageLength, out int count)
		{
			
			return GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(null, _companyId, _stockFileId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStockFiles table. Table EmailToSendStocks is related to table StockFiles
		///		through the (M:N) relationship defined in the EmailToSendStockByStockFiles table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockFileId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of EmailToSendStocks objects.</returns>
		public abstract TList<EmailToSendStocks> GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles(TransactionManager transactionManager,System.Int32 _companyId, System.Int32 _stockFileId, int start, int pageLength, out int count);
		
		#endregion GetByCompanyIdStockFileIdFromEmailToSendStockByStockFiles
		
		#region GetByCompanyIdStockIdFromEmailToSendStockByStocks
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStocks table. Table EmailToSendStocks is related to table Stock
		///		through the (M:N) relationship defined in the EmailToSendStockByStocks table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_stockId"></param>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockIdFromEmailToSendStockByStocks(System.Int32 _companyId, System.Int32 _stockId)
		{
			int count = -1;
			return GetByCompanyIdStockIdFromEmailToSendStockByStocks(null,_companyId, _stockId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStocks table. Table EmailToSendStocks is related to table Stock
		///		through the (M:N) relationship defined in the EmailToSendStockByStocks table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockIdFromEmailToSendStockByStocks(System.Int32 _companyId, System.Int32 _stockId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdStockIdFromEmailToSendStockByStocks(null, _companyId, _stockId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStocks table. Table EmailToSendStocks is related to table Stock
		///		through the (M:N) relationship defined in the EmailToSendStockByStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockIdFromEmailToSendStockByStocks(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _stockId)
		{
			int count = -1;
			return GetByCompanyIdStockIdFromEmailToSendStockByStocks(transactionManager, _companyId, _stockId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStocks table. Table EmailToSendStocks is related to table Stock
		///		through the (M:N) relationship defined in the EmailToSendStockByStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockIdFromEmailToSendStockByStocks(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _stockId,int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdStockIdFromEmailToSendStockByStocks(transactionManager, _companyId, _stockId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStocks table. Table EmailToSendStocks is related to table Stock
		///		through the (M:N) relationship defined in the EmailToSendStockByStocks table.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_stockId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyIdStockIdFromEmailToSendStockByStocks(System.Int32 _companyId, System.Int32 _stockId,int start, int pageLength, out int count)
		{
			
			return GetByCompanyIdStockIdFromEmailToSendStockByStocks(null, _companyId, _stockId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets EmailToSendStocks objects from the datasource by CompanyID in the
		///		EmailToSendStockByStocks table. Table EmailToSendStocks is related to table Stock
		///		through the (M:N) relationship defined in the EmailToSendStockByStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_companyId"></param>
		/// <param name="_stockId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of EmailToSendStocks objects.</returns>
		public abstract TList<EmailToSendStocks> GetByCompanyIdStockIdFromEmailToSendStockByStocks(TransactionManager transactionManager,System.Int32 _companyId, System.Int32 _stockId, int start, int pageLength, out int count);
		
		#endregion GetByCompanyIdStockIdFromEmailToSendStockByStocks
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, GPSTrackingDBV2.Entities.EmailToSendStocksKey key)
		{
			return Delete(transactionManager, key.CompanyId, key.EmailToSendStockId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_companyId">. Primary Key.</param>
		/// <param name="_emailToSendStockId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _companyId, System.Int32 _emailToSendStockId)
		{
			return Delete(null, _companyId, _emailToSendStockId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId">. Primary Key.</param>
		/// <param name="_emailToSendStockId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _emailToSendStockId);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Companies key.
		///		FK_EmailToSendStocks_Companies Description: 
		/// </summary>
		/// <param name="_companyId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyId(System.Int32 _companyId)
		{
			int count = -1;
			return GetByCompanyId(_companyId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Companies key.
		///		FK_EmailToSendStocks_Companies Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		/// <remarks></remarks>
		public TList<EmailToSendStocks> GetByCompanyId(TransactionManager transactionManager, System.Int32 _companyId)
		{
			int count = -1;
			return GetByCompanyId(transactionManager, _companyId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Companies key.
		///		FK_EmailToSendStocks_Companies Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyId(TransactionManager transactionManager, System.Int32 _companyId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyId(transactionManager, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Companies key.
		///		fkEmailToSendStocksCompanies Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyId(System.Int32 _companyId, int start, int pageLength)
		{
			int count =  -1;
			return GetByCompanyId(null, _companyId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Companies key.
		///		fkEmailToSendStocksCompanies Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_companyId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByCompanyId(System.Int32 _companyId, int start, int pageLength,out int count)
		{
			return GetByCompanyId(null, _companyId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Companies key.
		///		FK_EmailToSendStocks_Companies Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public abstract TList<EmailToSendStocks> GetByCompanyId(TransactionManager transactionManager, System.Int32 _companyId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Status key.
		///		FK_EmailToSendStocks_Status Description: 
		/// </summary>
		/// <param name="_statusId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByStatusId(System.String _statusId)
		{
			int count = -1;
			return GetByStatusId(_statusId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Status key.
		///		FK_EmailToSendStocks_Status Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_statusId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		/// <remarks></remarks>
		public TList<EmailToSendStocks> GetByStatusId(TransactionManager transactionManager, System.String _statusId)
		{
			int count = -1;
			return GetByStatusId(transactionManager, _statusId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Status key.
		///		FK_EmailToSendStocks_Status Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_statusId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByStatusId(TransactionManager transactionManager, System.String _statusId, int start, int pageLength)
		{
			int count = -1;
			return GetByStatusId(transactionManager, _statusId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Status key.
		///		fkEmailToSendStocksStatus Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_statusId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByStatusId(System.String _statusId, int start, int pageLength)
		{
			int count =  -1;
			return GetByStatusId(null, _statusId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Status key.
		///		fkEmailToSendStocksStatus Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_statusId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public TList<EmailToSendStocks> GetByStatusId(System.String _statusId, int start, int pageLength,out int count)
		{
			return GetByStatusId(null, _statusId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_EmailToSendStocks_Status key.
		///		FK_EmailToSendStocks_Status Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_statusId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.EmailToSendStocks objects.</returns>
		public abstract TList<EmailToSendStocks> GetByStatusId(TransactionManager transactionManager, System.String _statusId, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override GPSTrackingDBV2.Entities.EmailToSendStocks Get(TransactionManager transactionManager, GPSTrackingDBV2.Entities.EmailToSendStocksKey key, int start, int pageLength)
		{
			return GetByCompanyIdEmailToSendStockId(transactionManager, key.CompanyId, key.EmailToSendStockId, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_EmailToSendStocks index.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_emailToSendStockId"></param>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> class.</returns>
		public GPSTrackingDBV2.Entities.EmailToSendStocks GetByCompanyIdEmailToSendStockId(System.Int32 _companyId, System.Int32 _emailToSendStockId)
		{
			int count = -1;
			return GetByCompanyIdEmailToSendStockId(null,_companyId, _emailToSendStockId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_EmailToSendStocks index.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_emailToSendStockId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> class.</returns>
		public GPSTrackingDBV2.Entities.EmailToSendStocks GetByCompanyIdEmailToSendStockId(System.Int32 _companyId, System.Int32 _emailToSendStockId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdEmailToSendStockId(null, _companyId, _emailToSendStockId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_EmailToSendStocks index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_emailToSendStockId"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> class.</returns>
		public GPSTrackingDBV2.Entities.EmailToSendStocks GetByCompanyIdEmailToSendStockId(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _emailToSendStockId)
		{
			int count = -1;
			return GetByCompanyIdEmailToSendStockId(transactionManager, _companyId, _emailToSendStockId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_EmailToSendStocks index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_emailToSendStockId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> class.</returns>
		public GPSTrackingDBV2.Entities.EmailToSendStocks GetByCompanyIdEmailToSendStockId(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _emailToSendStockId, int start, int pageLength)
		{
			int count = -1;
			return GetByCompanyIdEmailToSendStockId(transactionManager, _companyId, _emailToSendStockId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_EmailToSendStocks index.
		/// </summary>
		/// <param name="_companyId"></param>
		/// <param name="_emailToSendStockId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> class.</returns>
		public GPSTrackingDBV2.Entities.EmailToSendStocks GetByCompanyIdEmailToSendStockId(System.Int32 _companyId, System.Int32 _emailToSendStockId, int start, int pageLength, out int count)
		{
			return GetByCompanyIdEmailToSendStockId(null, _companyId, _emailToSendStockId, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_EmailToSendStocks index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_companyId"></param>
		/// <param name="_emailToSendStockId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> class.</returns>
		public abstract GPSTrackingDBV2.Entities.EmailToSendStocks GetByCompanyIdEmailToSendStockId(TransactionManager transactionManager, System.Int32 _companyId, System.Int32 _emailToSendStockId, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;EmailToSendStocks&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;EmailToSendStocks&gt;"/></returns>
		public static TList<EmailToSendStocks> Fill(IDataReader reader, TList<EmailToSendStocks> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				GPSTrackingDBV2.Entities.EmailToSendStocks c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("EmailToSendStocks")
					.Append("|").Append((System.Int32)reader[((int)EmailToSendStocksColumn.CompanyId - 1)])
					.Append("|").Append((System.Int32)reader[((int)EmailToSendStocksColumn.EmailToSendStockId - 1)]).ToString();
					c = EntityManager.LocateOrCreate<EmailToSendStocks>(
					key.ToString(), // EntityTrackingKey
					"EmailToSendStocks",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new GPSTrackingDBV2.Entities.EmailToSendStocks();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.CompanyId = (System.Int32)reader[((int)EmailToSendStocksColumn.CompanyId - 1)];
					c.OriginalCompanyId = c.CompanyId;
					c.EmailToSendStockId = (System.Int32)reader[((int)EmailToSendStocksColumn.EmailToSendStockId - 1)];
					c.OriginalEmailToSendStockId = c.EmailToSendStockId;
					c.StatusId = (reader.IsDBNull(((int)EmailToSendStocksColumn.StatusId - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.StatusId - 1)];
					c.UsernameTransaction = (reader.IsDBNull(((int)EmailToSendStocksColumn.UsernameTransaction - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.UsernameTransaction - 1)];
					c.UuidTransaction = (reader.IsDBNull(((int)EmailToSendStocksColumn.UuidTransaction - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.UuidTransaction - 1)];
					c.CreationDate = (reader.IsDBNull(((int)EmailToSendStocksColumn.CreationDate - 1)))?null:(System.DateTime?)reader[((int)EmailToSendStocksColumn.CreationDate - 1)];
					c.TypeUserTransaction = (reader.IsDBNull(((int)EmailToSendStocksColumn.TypeUserTransaction - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.TypeUserTransaction - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, GPSTrackingDBV2.Entities.EmailToSendStocks entity)
		{
			if (!reader.Read()) return;
			
			entity.CompanyId = (System.Int32)reader[((int)EmailToSendStocksColumn.CompanyId - 1)];
			entity.OriginalCompanyId = (System.Int32)reader["CompanyID"];
			entity.EmailToSendStockId = (System.Int32)reader[((int)EmailToSendStocksColumn.EmailToSendStockId - 1)];
			entity.OriginalEmailToSendStockId = (System.Int32)reader["EmailToSendStockID"];
			entity.StatusId = (reader.IsDBNull(((int)EmailToSendStocksColumn.StatusId - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.StatusId - 1)];
			entity.UsernameTransaction = (reader.IsDBNull(((int)EmailToSendStocksColumn.UsernameTransaction - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.UsernameTransaction - 1)];
			entity.UuidTransaction = (reader.IsDBNull(((int)EmailToSendStocksColumn.UuidTransaction - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.UuidTransaction - 1)];
			entity.CreationDate = (reader.IsDBNull(((int)EmailToSendStocksColumn.CreationDate - 1)))?null:(System.DateTime?)reader[((int)EmailToSendStocksColumn.CreationDate - 1)];
			entity.TypeUserTransaction = (reader.IsDBNull(((int)EmailToSendStocksColumn.TypeUserTransaction - 1)))?null:(System.String)reader[((int)EmailToSendStocksColumn.TypeUserTransaction - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, GPSTrackingDBV2.Entities.EmailToSendStocks entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.CompanyId = (System.Int32)dataRow["CompanyID"];
			entity.OriginalCompanyId = (System.Int32)dataRow["CompanyID"];
			entity.EmailToSendStockId = (System.Int32)dataRow["EmailToSendStockID"];
			entity.OriginalEmailToSendStockId = (System.Int32)dataRow["EmailToSendStockID"];
			entity.StatusId = Convert.IsDBNull(dataRow["StatusID"]) ? null : (System.String)dataRow["StatusID"];
			entity.UsernameTransaction = Convert.IsDBNull(dataRow["UsernameTransaction"]) ? null : (System.String)dataRow["UsernameTransaction"];
			entity.UuidTransaction = Convert.IsDBNull(dataRow["UuidTransaction"]) ? null : (System.String)dataRow["UuidTransaction"];
			entity.CreationDate = Convert.IsDBNull(dataRow["CreationDate"]) ? null : (System.DateTime?)dataRow["CreationDate"];
			entity.TypeUserTransaction = Convert.IsDBNull(dataRow["TypeUserTransaction"]) ? null : (System.String)dataRow["TypeUserTransaction"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.EmailToSendStocks"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">GPSTrackingDBV2.Entities.EmailToSendStocks Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, GPSTrackingDBV2.Entities.EmailToSendStocks entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region CompanyIdSource	
			if (CanDeepLoad(entity, "Companies|CompanyIdSource", deepLoadType, innerList) 
				&& entity.CompanyIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.CompanyId;
				Companies tmpEntity = EntityManager.LocateEntity<Companies>(EntityLocator.ConstructKeyFromPkItems(typeof(Companies), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.CompanyIdSource = tmpEntity;
				else
					entity.CompanyIdSource = DataRepository.CompaniesProvider.GetByCompanyId(transactionManager, entity.CompanyId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'CompanyIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.CompanyIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.CompaniesProvider.DeepLoad(transactionManager, entity.CompanyIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion CompanyIdSource

			#region StatusIdSource	
			if (CanDeepLoad(entity, "Status|StatusIdSource", deepLoadType, innerList) 
				&& entity.StatusIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = (entity.StatusId ?? string.Empty);
				Status tmpEntity = EntityManager.LocateEntity<Status>(EntityLocator.ConstructKeyFromPkItems(typeof(Status), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.StatusIdSource = tmpEntity;
				else
					entity.StatusIdSource = DataRepository.StatusProvider.GetByStatusId(transactionManager, (entity.StatusId ?? string.Empty));		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'StatusIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.StatusIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.StatusProvider.DeepLoad(transactionManager, entity.StatusIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion StatusIdSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByCompanyIdEmailToSendStockId methods when available
			
			#region EmailToSendStockByClientsCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<EmailToSendStockByClients>|EmailToSendStockByClientsCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'EmailToSendStockByClientsCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.EmailToSendStockByClientsCollection = DataRepository.EmailToSendStockByClientsProvider.GetByCompanyIdEmailToSendStockId(transactionManager, entity.CompanyId, entity.EmailToSendStockId);

				if (deep && entity.EmailToSendStockByClientsCollection.Count > 0)
				{
					deepHandles.Add("EmailToSendStockByClientsCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<EmailToSendStockByClients>) DataRepository.EmailToSendStockByClientsProvider.DeepLoad,
						new object[] { transactionManager, entity.EmailToSendStockByClientsCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region EmailToSendStockByStockFilesCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<EmailToSendStockByStockFiles>|EmailToSendStockByStockFilesCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'EmailToSendStockByStockFilesCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.EmailToSendStockByStockFilesCollection = DataRepository.EmailToSendStockByStockFilesProvider.GetByCompanyIdEmailToSendStockId(transactionManager, entity.CompanyId, entity.EmailToSendStockId);

				if (deep && entity.EmailToSendStockByStockFilesCollection.Count > 0)
				{
					deepHandles.Add("EmailToSendStockByStockFilesCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<EmailToSendStockByStockFiles>) DataRepository.EmailToSendStockByStockFilesProvider.DeepLoad,
						new object[] { transactionManager, entity.EmailToSendStockByStockFilesCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region EmailToSendStockByStocksCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<EmailToSendStockByStocks>|EmailToSendStockByStocksCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'EmailToSendStockByStocksCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.EmailToSendStockByStocksCollection = DataRepository.EmailToSendStockByStocksProvider.GetByCompanyIdEmailToSendStockId(transactionManager, entity.CompanyId, entity.EmailToSendStockId);

				if (deep && entity.EmailToSendStockByStocksCollection.Count > 0)
				{
					deepHandles.Add("EmailToSendStockByStocksCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<EmailToSendStockByStocks>) DataRepository.EmailToSendStockByStocksProvider.DeepLoad,
						new object[] { transactionManager, entity.EmailToSendStockByStocksCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region ClientIdClientsCollection_From_EmailToSendStockByClients
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<Clients>|ClientIdClientsCollection_From_EmailToSendStockByClients", deepLoadType, innerList))
			{
				entity.ClientIdClientsCollection_From_EmailToSendStockByClients = DataRepository.ClientsProvider.GetByCompanyIdEmailToSendStockIdFromEmailToSendStockByClients(transactionManager, entity.CompanyId, entity.EmailToSendStockId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'ClientIdClientsCollection_From_EmailToSendStockByClients' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.ClientIdClientsCollection_From_EmailToSendStockByClients != null)
				{
					deepHandles.Add("ClientIdClientsCollection_From_EmailToSendStockByClients",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< Clients >) DataRepository.ClientsProvider.DeepLoad,
						new object[] { transactionManager, entity.ClientIdClientsCollection_From_EmailToSendStockByClients, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<StockFiles>|CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles", deepLoadType, innerList))
			{
				entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles = DataRepository.StockFilesProvider.GetByCompanyIdEmailToSendStockIdFromEmailToSendStockByStockFiles(transactionManager, entity.CompanyId, entity.EmailToSendStockId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles != null)
				{
					deepHandles.Add("CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< StockFiles >) DataRepository.StockFilesProvider.DeepLoad,
						new object[] { transactionManager, entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<Stock>|CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks", deepLoadType, innerList))
			{
				entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks = DataRepository.StockProvider.GetByCompanyIdEmailToSendStockIdFromEmailToSendStockByStocks(transactionManager, entity.CompanyId, entity.EmailToSendStockId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks != null)
				{
					deepHandles.Add("CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< Stock >) DataRepository.StockProvider.DeepLoad,
						new object[] { transactionManager, entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the GPSTrackingDBV2.Entities.EmailToSendStocks object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">GPSTrackingDBV2.Entities.EmailToSendStocks instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">GPSTrackingDBV2.Entities.EmailToSendStocks Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, GPSTrackingDBV2.Entities.EmailToSendStocks entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region CompanyIdSource
			if (CanDeepSave(entity, "Companies|CompanyIdSource", deepSaveType, innerList) 
				&& entity.CompanyIdSource != null)
			{
				DataRepository.CompaniesProvider.Save(transactionManager, entity.CompanyIdSource);
				entity.CompanyId = entity.CompanyIdSource.CompanyId;
			}
			#endregion 
			
			#region StatusIdSource
			if (CanDeepSave(entity, "Status|StatusIdSource", deepSaveType, innerList) 
				&& entity.StatusIdSource != null)
			{
				DataRepository.StatusProvider.Save(transactionManager, entity.StatusIdSource);
				entity.StatusId = entity.StatusIdSource.StatusId;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();

			#region ClientIdClientsCollection_From_EmailToSendStockByClients>
			if (CanDeepSave(entity.ClientIdClientsCollection_From_EmailToSendStockByClients, "List<Clients>|ClientIdClientsCollection_From_EmailToSendStockByClients", deepSaveType, innerList))
			{
				if (entity.ClientIdClientsCollection_From_EmailToSendStockByClients.Count > 0 || entity.ClientIdClientsCollection_From_EmailToSendStockByClients.DeletedItems.Count > 0)
				{
					DataRepository.ClientsProvider.Save(transactionManager, entity.ClientIdClientsCollection_From_EmailToSendStockByClients); 
					deepHandles.Add("ClientIdClientsCollection_From_EmailToSendStockByClients",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<Clients>) DataRepository.ClientsProvider.DeepSave,
						new object[] { transactionManager, entity.ClientIdClientsCollection_From_EmailToSendStockByClients, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles>
			if (CanDeepSave(entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles, "List<StockFiles>|CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles", deepSaveType, innerList))
			{
				if (entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles.Count > 0 || entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles.DeletedItems.Count > 0)
				{
					DataRepository.StockFilesProvider.Save(transactionManager, entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles); 
					deepHandles.Add("CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<StockFiles>) DataRepository.StockFilesProvider.DeepSave,
						new object[] { transactionManager, entity.CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks>
			if (CanDeepSave(entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks, "List<Stock>|CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks", deepSaveType, innerList))
			{
				if (entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks.Count > 0 || entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks.DeletedItems.Count > 0)
				{
					DataRepository.StockProvider.Save(transactionManager, entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks); 
					deepHandles.Add("CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<Stock>) DataRepository.StockProvider.DeepSave,
						new object[] { transactionManager, entity.CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 
	
			#region List<EmailToSendStockByClients>
				if (CanDeepSave(entity.EmailToSendStockByClientsCollection, "List<EmailToSendStockByClients>|EmailToSendStockByClientsCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(EmailToSendStockByClients child in entity.EmailToSendStockByClientsCollection)
					{
						if(child.CompanyIdEmailToSendStockIdSource != null)
						{
								child.CompanyId = child.CompanyIdEmailToSendStockIdSource.CompanyId;
								child.EmailToSendStockId = child.CompanyIdEmailToSendStockIdSource.EmailToSendStockId;
						}

						if(child.ClientIdSource != null)
						{
								child.ClientId = child.ClientIdSource.ClientId;
						}

					}

					if (entity.EmailToSendStockByClientsCollection.Count > 0 || entity.EmailToSendStockByClientsCollection.DeletedItems.Count > 0)
					{
						//DataRepository.EmailToSendStockByClientsProvider.Save(transactionManager, entity.EmailToSendStockByClientsCollection);
						
						deepHandles.Add("EmailToSendStockByClientsCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< EmailToSendStockByClients >) DataRepository.EmailToSendStockByClientsProvider.DeepSave,
							new object[] { transactionManager, entity.EmailToSendStockByClientsCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<EmailToSendStockByStockFiles>
				if (CanDeepSave(entity.EmailToSendStockByStockFilesCollection, "List<EmailToSendStockByStockFiles>|EmailToSendStockByStockFilesCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(EmailToSendStockByStockFiles child in entity.EmailToSendStockByStockFilesCollection)
					{
						if(child.CompanyIdEmailToSendStockIdSource != null)
						{
								child.CompanyId = child.CompanyIdEmailToSendStockIdSource.CompanyId;
								child.EmailToSendStockId = child.CompanyIdEmailToSendStockIdSource.EmailToSendStockId;
						}

						if(child.CompanyIdStockFileIdSource != null)
						{
								child.CompanyId = child.CompanyIdStockFileIdSource.CompanyId;
								child.StockFileId = child.CompanyIdStockFileIdSource.StockFileId;
						}

					}

					if (entity.EmailToSendStockByStockFilesCollection.Count > 0 || entity.EmailToSendStockByStockFilesCollection.DeletedItems.Count > 0)
					{
						//DataRepository.EmailToSendStockByStockFilesProvider.Save(transactionManager, entity.EmailToSendStockByStockFilesCollection);
						
						deepHandles.Add("EmailToSendStockByStockFilesCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< EmailToSendStockByStockFiles >) DataRepository.EmailToSendStockByStockFilesProvider.DeepSave,
							new object[] { transactionManager, entity.EmailToSendStockByStockFilesCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<EmailToSendStockByStocks>
				if (CanDeepSave(entity.EmailToSendStockByStocksCollection, "List<EmailToSendStockByStocks>|EmailToSendStockByStocksCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(EmailToSendStockByStocks child in entity.EmailToSendStockByStocksCollection)
					{
						if(child.CompanyIdEmailToSendStockIdSource != null)
						{
								child.CompanyId = child.CompanyIdEmailToSendStockIdSource.CompanyId;
								child.EmailToSendStockId = child.CompanyIdEmailToSendStockIdSource.EmailToSendStockId;
						}

						if(child.CompanyIdStockIdSource != null)
						{
								child.CompanyId = child.CompanyIdStockIdSource.CompanyId;
								child.StockId = child.CompanyIdStockIdSource.StockId;
						}

					}

					if (entity.EmailToSendStockByStocksCollection.Count > 0 || entity.EmailToSendStockByStocksCollection.DeletedItems.Count > 0)
					{
						//DataRepository.EmailToSendStockByStocksProvider.Save(transactionManager, entity.EmailToSendStockByStocksCollection);
						
						deepHandles.Add("EmailToSendStockByStocksCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< EmailToSendStockByStocks >) DataRepository.EmailToSendStockByStocksProvider.DeepSave,
							new object[] { transactionManager, entity.EmailToSendStockByStocksCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region EmailToSendStocksChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>GPSTrackingDBV2.Entities.EmailToSendStocks</c>
	///</summary>
	public enum EmailToSendStocksChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>Companies</c> at CompanyIdSource
		///</summary>
		[ChildEntityType(typeof(Companies))]
		Companies,
			
		///<summary>
		/// Composite Property for <c>Status</c> at StatusIdSource
		///</summary>
		[ChildEntityType(typeof(Status))]
		Status,
	
		///<summary>
		/// Collection of <c>EmailToSendStocks</c> as OneToMany for EmailToSendStockByClientsCollection
		///</summary>
		[ChildEntityType(typeof(TList<EmailToSendStockByClients>))]
		EmailToSendStockByClientsCollection,

		///<summary>
		/// Collection of <c>EmailToSendStocks</c> as OneToMany for EmailToSendStockByStockFilesCollection
		///</summary>
		[ChildEntityType(typeof(TList<EmailToSendStockByStockFiles>))]
		EmailToSendStockByStockFilesCollection,

		///<summary>
		/// Collection of <c>EmailToSendStocks</c> as OneToMany for EmailToSendStockByStocksCollection
		///</summary>
		[ChildEntityType(typeof(TList<EmailToSendStockByStocks>))]
		EmailToSendStockByStocksCollection,

		///<summary>
		/// Collection of <c>EmailToSendStocks</c> as ManyToMany for ClientsCollection_From_EmailToSendStockByClients
		///</summary>
		[ChildEntityType(typeof(TList<Clients>))]
		ClientIdClientsCollection_From_EmailToSendStockByClients,

		///<summary>
		/// Collection of <c>EmailToSendStocks</c> as ManyToMany for StockFilesCollection_From_EmailToSendStockByStockFiles
		///</summary>
		[ChildEntityType(typeof(TList<StockFiles>))]
		CompanyIdStockFileIdStockFilesCollection_From_EmailToSendStockByStockFiles,

		///<summary>
		/// Collection of <c>EmailToSendStocks</c> as ManyToMany for StockCollection_From_EmailToSendStockByStocks
		///</summary>
		[ChildEntityType(typeof(TList<Stock>))]
		CompanyIdStockIdStockCollection_From_EmailToSendStockByStocks,
	}
	
	#endregion EmailToSendStocksChildEntityTypes
	
	#region EmailToSendStocksFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;EmailToSendStocksColumn&gt;"/> class
	/// that is used exclusively with a <see cref="EmailToSendStocks"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class EmailToSendStocksFilterBuilder : SqlFilterBuilder<EmailToSendStocksColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the EmailToSendStocksFilterBuilder class.
		/// </summary>
		public EmailToSendStocksFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the EmailToSendStocksFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public EmailToSendStocksFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the EmailToSendStocksFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public EmailToSendStocksFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion EmailToSendStocksFilterBuilder
	
	#region EmailToSendStocksParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;EmailToSendStocksColumn&gt;"/> class
	/// that is used exclusively with a <see cref="EmailToSendStocks"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class EmailToSendStocksParameterBuilder : ParameterizedSqlFilterBuilder<EmailToSendStocksColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the EmailToSendStocksParameterBuilder class.
		/// </summary>
		public EmailToSendStocksParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the EmailToSendStocksParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public EmailToSendStocksParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the EmailToSendStocksParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public EmailToSendStocksParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion EmailToSendStocksParameterBuilder
	
	#region EmailToSendStocksSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;EmailToSendStocksColumn&gt;"/> class
	/// that is used exclusively with a <see cref="EmailToSendStocks"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class EmailToSendStocksSortBuilder : SqlSortBuilder<EmailToSendStocksColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the EmailToSendStocksSqlSortBuilder class.
		/// </summary>
		public EmailToSendStocksSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion EmailToSendStocksSortBuilder
	
} // end namespace
